<template>
    <div>
        <p v-if="this.$store.state.app.complaintId === ''" align="center">
            <img style="width: 500px;margin-top: 25%" src="@/images/noData.png"/>
        </p>
        <Card v-if="this.$store.state.app.complaintId !== ''" style="font-family:STKaiti,Helvetica,sans-serif;font-size: 20px" shadow>
            <Row>
                <Col><Tag checkable color="red"><label>发病时间：</label></Tag>{{formItem.time | valueFilter}}</Col>
            </Row>
            <Row>
                <Col><Tag checkable color="red"><label>主诉内容：</label></Tag>{{formItem.content | valueFilter}}</Col>
            </Row>
            <Row>
                <Col><Tag checkable color="red"><label>发病情况：</label></Tag>{{formItem.situation | valueFilter}}</Col>
            </Row>
            <Row>
                <Col><Tag checkable color="red"><label>伴随症状：</label></Tag>{{formItem.symptom | valueFilter}}</Col>
            </Row>
            <Row>
                <Col><Tag checkable color="red"><label>治疗经过：</label></Tag>{{formItem.process | valueFilter}}</Col>
            </Row>
            <Row>
                <Col><Tag checkable color="red"><label>目前状况：</label></Tag>{{formItem.state | valueFilter}}</Col>
            </Row>
            <Row>
                <Col><Tag checkable color="red"><label>使用情况：</label></Tag>{{formItem.useSituation | valueFilter}}</Col>
            </Row>
            <Row>
                <Col><Tag checkable color="red"><label>其他情况：</label></Tag>{{formItem.otherSituation | valueFilter}}</Col>
            </Row>
        </Card>
    </div>
</template>

<script>
    export default {
        props: {
            id: {
                type: Number,
                default: -1
            },
        },
        data () {
            return {
                baseURL: '/user/complaint',
                selectRows: [],
                showModel: false,
                datas: [],
                formItem: {}
            };
        },
        filters: {
            valueFilter (value) {
                let temp = value
                if (temp === undefined || temp === '') {
                    temp = '无'
                }
                return temp
            }
        },
        methods: {
            init () {
                let url = this.baseURL + '/findById/' + this.id
                this.$bus.get(url).then((response) => {
                    let {code, data, msg} = response.data
                    if (code === 0) {
                        this.formItem = data
                    } else {
                        this.$bus.alert('error', msg)
                    }
                })
            }
        },
        watch: {
            id: function (val, oldVal) {
                let url = this.baseURL + '/findById/' + val
                this.$ajax.get(url).then((response) => {
                    let {code, data, msg} = response.data
                    if (code === 0) {
                        this.formItem = data
                    } else {
                        this.$bus.alert('error', msg)
                    }
                })
            }
        },
        beforeRouteEnter (to, from, next) {
            next(vm => {
                // vm.init()
            })
        }
    }
</script>

<style>
label{
    font-size: 20px;
}
</style>
